package cn.com.load;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

import cn.com.utils.Analysis;

public class ContentLoad {

	/**
	 * 将指定路径的输入文件,解析后,输出到对应的路径
	 * 
	 * @param input
	 * @param output
	 */
	public static void loadByFile(File input, File output) {

		BufferedReader br = null;
		FileWriter fr = null;
		try {
			FileInputStream fis = new FileInputStream(input);
			InputStreamReader isr = new InputStreamReader(fis,"GBK");
			br = new BufferedReader(isr);
			// true 为追加 , false为覆盖
			fr = new FileWriter(output, true);
			String tmp = "";
			while ((tmp = br.readLine()) != null) {
				// 输出到指定的文件中
				// analysisToUser User 字符串解析方法
				fr.write(Analysis.analysisToContent(tmp));
				fr.write("\n");
				fr.flush();
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}
}
